package com.ayu.shortlink.project.controller;

import com.ayu.shortlink.project.common.convention.result.Result;
import com.ayu.shortlink.project.common.convention.result.Results;
import com.ayu.shortlink.project.dto.req.*;
import com.ayu.shortlink.project.dto.resp.ShortLinkPageRespDTO;
import com.ayu.shortlink.project.service.RecycleBinService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 回收站控制层
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    /**
     * 短链接添加至回收站
     */
    @PostMapping("/api/short-link/v1/recycle-bin/save")
    public Result<Void> save(@RequestBody RecycleBinSaveReqDTO requestParam){
        recycleBinService.saveRecycleBin(requestParam);
        return Results.success();
    }

//    /**
//     * 分页查询回收站短链接
//     */
//    @GetMapping("/api/short-link/v1/recycle-bin/page")
//    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkPageReqDTO requestParam){
//        return Results.success(recycleBinService.getPage(requestParam));
//    }

    /**
     * 分页查询回收站短链接
     */
    @GetMapping("/api/short-link/v1/recycle-bin/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(ShortLinkRecycleBinPageReqDTO requestParam){
        return Results.success(recycleBinService.getRecycleBinPage(requestParam));
    }

    /**
     * 恢复回收站短链接
     */
    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    public Result<Void> recover(@RequestBody RecycleBinRecoverReqDTO requestParam){
        recycleBinService.recover(requestParam);
        return Results.success();
    }

    /**
     * 删除回收站短链接
     */
    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    public Result<Void> remove(@RequestBody RecycleBinRemoveReqDTO requestParam){
        recycleBinService.removeRecycleBin(requestParam);
        return Results.success();
    }
}
